﻿// W_cqrk.cpp : 实现文件
//

#include "stdafx.h"
#include "suny.h"
#include "W_cqrk.h"
#include "afxdialogex.h"
#include "F_CONNECT.h"

// CW_cqrk 对话框

IMPLEMENT_DYNAMIC(CW_cqrk, CDialogEx)

CW_cqrk::CW_cqrk(CWnd* pParent /*=NULL*/)
	: CDialogEx(CW_cqrk::IDD, pParent)
{

}

CW_cqrk::~CW_cqrk()
{
}

void CW_cqrk::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_LIST1, m_list_yhzc);
	DDX_Control(pDX, IDC_STATIC1, m_con_kuang);
	DDX_Control(pDX, IDC_LIST2, m_list);
	DDX_Control(pDX, IDC_EDIT22, m_con_klx);
	DDX_Control(pDX, IDC_EDIT1, m_con_hyzh);
	DDX_Control(pDX, IDC_EDIT4, m_con_wkhm);
	DDX_Control(pDX, IDC_EDIT5, m_con_hyxm);
	DDX_Control(pDX, IDC_COMBO1, m_con_hyxb);
	DDX_Control(pDX, IDC_EDIT14, m_con_gddh);
	DDX_Control(pDX, IDC_EDIT15, m_con_yddh);
	DDX_Control(pDX, IDC_EDIT16, m_con_sfzh);
	DDX_Control(pDX, IDC_EDIT17, m_con_cphm);
	DDX_Control(pDX, IDC_EDIT18, m_con_zhje);
	DDX_Control(pDX, IDC_EDIT19, m_con_yhje);
	DDX_Control(pDX, IDC_EDIT20, m_con_czy);
	DDX_Control(pDX, IDC_EDIT21, m_con_kkwd);
	DDX_Control(pDX, IDC_EDIT25, m_con_czje);
	DDX_Control(pDX, IDC_EDIT24, m_con_zsje);
	DDX_Control(pDX, IDC_EDIT26, m_con_wded);
	DDX_Control(pDX, IDC_COMBO7, m_con_czfs);
}


BEGIN_MESSAGE_MAP(CW_cqrk, CDialogEx)
	ON_WM_PAINT()
	ON_BN_CLICKED(IDC_BUTTON3, &CW_cqrk::OnBnClickedButton3)
	ON_WM_SIZE()
	ON_BN_CLICKED(IDC_BUTTON1, &CW_cqrk::OnBnClickedButton1)
	ON_BN_CLICKED(IDC_BUTTON2, &CW_cqrk::OnBnClickedButton2)
	ON_NOTIFY(NM_DBLCLK, IDC_LIST2, &CW_cqrk::OnNMDblclkList2)
	ON_EN_CHANGE(IDC_EDIT25, &CW_cqrk::OnEnChangeEdit25)
END_MESSAGE_MAP()


// CW_cqrk 消息处理程序


void CW_cqrk::OnPaint()
{
	CPaintDC dc(this); // device context for painting
	CRect rect;
	CRect viewrect;
	CBrush brush(RGB(25,25,112));
	CFont m_fontlogo;

	GetClientRect(&viewrect);
	rect.top = 0;
	rect.left = 0;
	rect.bottom =39;
	rect.right = viewrect.right;
	
	dc.FillRect(&rect,&brush);
	
	m_fontlogo.CreateFont(28,0,0,0,FW_BOLD,true,FALSE,0,0,0,0,0,0,_T("宋体"));
	CString ls_logotext;
	
	ls_logotext = _T("会员卡充值");
	dc.SetBkMode(TRANSPARENT);
	CFont *oldfont = dc.SelectObject(&m_fontlogo);

	COLORREF oldcolor = dc.SetTextColor(::GetSysColor(COLOR_3DHILIGHT));
	dc.TextOut(10,5,ls_logotext);
	dc.SetTextColor(::GetSysColor(COLOR_3DSHADOW));
	dc.TextOut(9,4,ls_logotext);
	dc.SelectObject(oldfont);
	dc.SetTextColor(oldcolor);
	m_fontlogo.DeleteObject();
 		
	dc.SelectObject(oldfont);
	dc.SetTextColor(oldcolor);
	m_fontlogo.DeleteObject();
}


BOOL CW_cqrk::PreTranslateMessage(MSG* pMsg)
{
	if (pMsg->message == WM_KEYDOWN)
	{
		switch (pMsg->wParam)
		{
		case VK_RETURN:
			return true;
		case VK_ESCAPE:
			return true;
		default:
			break;
		}
	}

	return CDialogEx::PreTranslateMessage(pMsg);
}


void CW_cqrk::OnBnClickedButton3()
{
	CString ls_czje;
	CString ls_zsje;
	CF_CONNECT f_connect;
	ns4__lc_USCOREdata l_info;
	CString ls_stra;
	CString ls_suba;
	CString ls_czfs;
			
	if (is_hyzh.GetLength() == 0)
	{
		MessageBox(_T("请确定要充值的会员卡信息!"), _T("系统提示"), MB_ICONWARNING);
		return;
	}

	m_con_czje.GetWindowTextW(ls_czje);
	if (ls_czje.GetLength() == 0)
	{
		MessageBox(_T("请输入充值金额!"), _T("系统提示"), MB_ICONWARNING);
		m_con_czje.SetFocus();
		return;
	}

	m_con_zsje.GetWindowTextW(ls_zsje);
	if (ls_zsje.GetLength() == 0)
	{
		MessageBox(_T("请确定赠送金额!"), _T("系统提示"), MB_ICONWARNING);
		m_con_zsje.SetFocus();
		return;
	}

	m_con_czfs.GetWindowTextW(ls_czfs);
	if (ls_czfs.GetLength() == 0)
	{
		MessageBox(_T("请选择收款方式!"), _T("系统提示"), MB_ICONWARNING);
		return;
	}

	if (MessageBox(_T("请确定是否对该会员进行充值操作? [ " + ls_czje +  " ]元"), _T("系统提示"),MB_YESNO) == IDNO)
	{
		return;
	}

	GetDlgItem(IDC_BUTTON3)->EnableWindow(FALSE);
	l_info.CMD = "BH";
	l_info.VALUE01 = f_connect.f_getstd(theApp.gs_opid);
	l_info.VALUE02 = f_connect.f_getstd(theApp.gs_opxm);
	l_info.VALUE03 = f_connect.f_getstd(theApp.gs_bcode);
	l_info.VALUE04 = f_connect.f_getstd(ls_czje);
	l_info.VALUE05 = f_connect.f_getstd(ls_zsje);
	l_info.VALUE06 = f_connect.f_getstd(is_hyzh);
	l_info.VALUE07 = f_connect.f_getstd(ls_czfs);
	ls_stra = f_connect.f_server(l_info);
	if (f_connect.f_getsub(ls_stra,1) == "ZZ00")
	{		
		MessageBox(_T("充值成功!"),_T("系统提示"), MB_ICONINFORMATION);
		is_danj = _T("");
		is_jysj = _T("");
		is_yyye = _T("");
		is_czje = _T("");
		is_zsje = _T("");
		is_kkye = _T("");
		ls_suba = f_connect.f_getsub(ls_stra,4);
		m_con_wded.SetWindowTextW(f_connect.f_getsub_col(ls_suba,1));
		is_danj = f_connect.f_getsub_col(ls_suba, 2);
		is_jysj = f_connect.f_getsub_col(ls_suba, 3);
		is_yyye = f_connect.f_getsub_col(ls_suba, 4);
		is_czje = f_connect.f_getsub_col(ls_suba, 5);
		is_zsje = f_connect.f_getsub_col(ls_suba, 6);
		is_kkye = f_connect.f_getsub_col(ls_suba, 7);
		f_print();
		OnBnClickedButton2();
	}
	else if (f_connect.f_getsub(ls_stra,1) == "ZZ01")
	{
		MessageBox(f_connect.f_getsub(ls_stra,2),_T("系统提示"), MB_ICONWARNING);
	}
	GetDlgItem(IDC_BUTTON3)->EnableWindow(TRUE);	
}

void CW_cqrk::f_print()
{	
	HDC hdcprint; // 定义一个设备环境句柄       
	CFont lf_font;	
	CStringA ls_text;
	CStringA ls_temp;
	int li_jump = 0;
	int li_len = 0;

	lf_font.CreatePointFont(190, _T("MingLiU"));

	//定义一个打印作业   
	static DOCINFOA di = { sizeof(DOCINFOA), "printer", NULL };
	//得到设备字符串存入数组szprinter中   
	hdcprint = CreateDCA("winspool", "POS-58", theApp.gs_print_port, NULL);
	if (StartDocA(hdcprint, &di)>0) //开始执行一个打印作业   
	{
		StartPage(hdcprint); //打印机走纸,开始打印   
		SaveDC(hdcprint); //保存打印机设备句柄
		SelectObject(hdcprint, lf_font);
		
		//输出抬头		
		ls_text = "         湖北新捷支付系统";
		TextOutA(hdcprint, 0, li_jump, ls_text, ls_text.GetLength());
		
		li_jump += 35;
		MoveToEx(hdcprint, 0, li_jump, NULL);
		ls_text = "商户存根";
		TextOutA(hdcprint, 0, li_jump, ls_text, ls_text.GetLength());

		li_jump += 35;
		MoveToEx(hdcprint, 0, li_jump, NULL);
		ls_text = "-------------------------------------------------------";
		TextOutA(hdcprint, 0, li_jump, ls_text, ls_text.GetLength());

		li_jump += 35;
		MoveToEx(hdcprint, 0, li_jump, NULL);
		ls_text = "交易地点(MERCHANT NAME):";
		TextOutA(hdcprint, 0, li_jump, ls_text, ls_text.GetLength());

		li_jump += 35;	
		ls_text = theApp.gs_bname;
		MoveToEx(hdcprint, 0, li_jump, NULL);		
		TextOutA(hdcprint, 0, li_jump, ls_text, ls_text.GetLength());

		li_jump += 35;		
		ls_text = theApp.gs_opid;
		ls_text = "0000" + ls_text;
		ls_text = "                  " + ls_text.Right(4);
		ls_text = ls_text.Right(11);
		ls_text = "操作员(OPERA NO.):" + ls_text;		
		MoveToEx(hdcprint, 0, li_jump, NULL);
		TextOutA(hdcprint, 0, li_jump, ls_text, ls_text.GetLength());

		CString ls_wkh;
		m_con_wkhm.GetWindowTextW(ls_wkh);
		li_jump += 35;
		ls_text = ls_wkh;		
		ls_text = "                  " + ls_text;
		ls_text = ls_text.Right(10);
		ls_text = "会员卡号(CARD NO.):" + ls_text;
		MoveToEx(hdcprint, 0, li_jump, NULL);
		TextOutA(hdcprint, 0, li_jump, ls_text, ls_text.GetLength());

		li_jump += 35;
		ls_text = is_danj;
		ls_text = "                  " + ls_text;
		ls_text = ls_text.Right(16);
		ls_text = "单据号(SNO.):" + ls_text;
		MoveToEx(hdcprint, 0, li_jump, NULL);
		TextOutA(hdcprint, 0, li_jump, ls_text, ls_text.GetLength());

		li_jump += 35;
		ls_text = "交易类型(TXN TYPE):      充值";
		MoveToEx(hdcprint, 0, li_jump, NULL);
		TextOutA(hdcprint, 0, li_jump, ls_text, ls_text.GetLength());

		li_jump += 35;
		ls_text = "交易时间(DATE/TIME):";
		MoveToEx(hdcprint, 0, li_jump, NULL);
		TextOutA(hdcprint, 0, li_jump, ls_text, ls_text.GetLength());

		li_jump += 35;
		ls_text = is_jysj;
		ls_text = "          " + ls_text;
		MoveToEx(hdcprint, 0, li_jump, NULL);
		TextOutA(hdcprint, 0, li_jump, ls_text, ls_text.GetLength());

		li_jump += 35;
		ls_text = "原有余额(ORIGINAL):";
		MoveToEx(hdcprint, 0, li_jump, NULL);
		TextOutA(hdcprint, 0, li_jump, ls_text, ls_text.GetLength());

		li_jump += 35;
		ls_text = is_yyye;
		ls_text = "￥:" + ls_text;
		ls_text = "                             " + ls_text;
		ls_text = ls_text.Right(29);
		MoveToEx(hdcprint, 0, li_jump, NULL);
		TextOutA(hdcprint, 0, li_jump, ls_text, ls_text.GetLength());

		li_jump += 35;
		ls_text = is_czje;
		ls_text = "￥:" + ls_text;
		ls_text = "                  " + ls_text;
		ls_text = ls_text.Right(12);
		ls_text = "充值金额(AMOUNT):" + ls_text;
		MoveToEx(hdcprint, 0, li_jump, NULL);
		TextOutA(hdcprint, 0, li_jump, ls_text, ls_text.GetLength());

		li_jump += 35;
		ls_text = is_zsje;
		ls_text = "￥:" + ls_text;
		ls_text = "                  " + ls_text;
		ls_text = ls_text.Right(14);		
		ls_text = "赠送金额(GIFT):" + ls_text;
		MoveToEx(hdcprint, 0, li_jump, NULL);
		TextOutA(hdcprint, 0, li_jump, ls_text, ls_text.GetLength());

		li_jump += 35;
		ls_text = is_kkye;
		ls_text = "￥:" + ls_text;
		ls_text = "                  " + ls_text;
		ls_text = ls_text.Right(13);
		ls_text = "卡余额(BALANCE):" + ls_text;
		MoveToEx(hdcprint, 0, li_jump, NULL);
		TextOutA(hdcprint, 0, li_jump, ls_text, ls_text.GetLength());

		li_jump += 35;
		MoveToEx(hdcprint, 0, li_jump, NULL);
		ls_text = "-------------------------------------------------------";
		TextOutA(hdcprint, 0, li_jump, ls_text, ls_text.GetLength());

		li_jump += 35;
		ls_text = "持卡人签名(SIGNATUR):";
		MoveToEx(hdcprint, 0, li_jump, NULL);
		TextOutA(hdcprint, 0, li_jump, ls_text, ls_text.GetLength());

		li_jump += 70;
		ls_text = "                ---------------";
		MoveToEx(hdcprint, 0, li_jump, NULL);
		TextOutA(hdcprint, 0, li_jump, ls_text, ls_text.GetLength());

		//////////////////////////--用户存根//////////////////////////////////////////////
		//输出抬头		
		li_jump += 105;
		ls_text = "         湖北新捷支付系统";
		TextOutA(hdcprint, 0, li_jump, ls_text, ls_text.GetLength());

		li_jump += 35;
		MoveToEx(hdcprint, 0, li_jump, NULL);
		ls_text = "用户存根";
		TextOutA(hdcprint, 0, li_jump, ls_text, ls_text.GetLength());

		li_jump += 35;
		MoveToEx(hdcprint, 0, li_jump, NULL);
		ls_text = "-------------------------------------------------------";
		TextOutA(hdcprint, 0, li_jump, ls_text, ls_text.GetLength());

		li_jump += 35;
		MoveToEx(hdcprint, 0, li_jump, NULL);
		ls_text = "交易地点(MERCHANT NAME):";
		TextOutA(hdcprint, 0, li_jump, ls_text, ls_text.GetLength());

		li_jump += 35;
		ls_text = theApp.gs_bname;
		MoveToEx(hdcprint, 0, li_jump, NULL);
		TextOutA(hdcprint, 0, li_jump, ls_text, ls_text.GetLength());

		li_jump += 35;
		ls_text = theApp.gs_opid;
		ls_text = "0000" + ls_text;
		ls_text = "                  " + ls_text.Right(4);
		ls_text = ls_text.Right(11);
		ls_text = "操作员(OPERA NO.):" + ls_text;
		MoveToEx(hdcprint, 0, li_jump, NULL);
		TextOutA(hdcprint, 0, li_jump, ls_text, ls_text.GetLength());

		li_jump += 35;
		ls_text = ls_wkh;
		ls_text = "                  " + ls_text;
		ls_text = ls_text.Right(10);
		ls_text = "会员卡号(CARD NO.):" + ls_text;
		MoveToEx(hdcprint, 0, li_jump, NULL);
		TextOutA(hdcprint, 0, li_jump, ls_text, ls_text.GetLength());

		li_jump += 35;
		ls_text = is_danj;
		ls_text = "                  " + ls_text;
		ls_text = ls_text.Right(16);
		ls_text = "单据号(SNO.):" + ls_text;
		MoveToEx(hdcprint, 0, li_jump, NULL);
		TextOutA(hdcprint, 0, li_jump, ls_text, ls_text.GetLength());

		li_jump += 35;
		ls_text = "交易类型(TXN TYPE):      充值";
		MoveToEx(hdcprint, 0, li_jump, NULL);
		TextOutA(hdcprint, 0, li_jump, ls_text, ls_text.GetLength());

		li_jump += 35;
		ls_text = "交易时间(DATE/TIME):";
		MoveToEx(hdcprint, 0, li_jump, NULL);
		TextOutA(hdcprint, 0, li_jump, ls_text, ls_text.GetLength());

		li_jump += 35;
		ls_text = is_jysj;
		ls_text = "          " + ls_text;
		MoveToEx(hdcprint, 0, li_jump, NULL);
		TextOutA(hdcprint, 0, li_jump, ls_text, ls_text.GetLength());

		li_jump += 35;
		ls_text = "原有余额(ORIGINAL):";
		MoveToEx(hdcprint, 0, li_jump, NULL);
		TextOutA(hdcprint, 0, li_jump, ls_text, ls_text.GetLength());

		li_jump += 35;
		ls_text = is_yyye;
		ls_text = "￥:" + ls_text;
		ls_text = "                             " + ls_text;
		ls_text = ls_text.Right(29);
		MoveToEx(hdcprint, 0, li_jump, NULL);
		TextOutA(hdcprint, 0, li_jump, ls_text, ls_text.GetLength());

		li_jump += 35;
		ls_text = is_czje;
		ls_text = "￥:" + ls_text;
		ls_text = "                  " + ls_text;
		ls_text = ls_text.Right(12);
		ls_text = "充值金额(AMOUNT):" + ls_text;
		MoveToEx(hdcprint, 0, li_jump, NULL);
		TextOutA(hdcprint, 0, li_jump, ls_text, ls_text.GetLength());

		li_jump += 35;
		ls_text = is_zsje;
		ls_text = "￥:" + ls_text;
		ls_text = "                  " + ls_text;
		ls_text = ls_text.Right(14);
		ls_text = "赠送金额(GIFT):" + ls_text;
		MoveToEx(hdcprint, 0, li_jump, NULL);
		TextOutA(hdcprint, 0, li_jump, ls_text, ls_text.GetLength());

		li_jump += 35;
		ls_text = is_kkye;
		ls_text = "￥:" + ls_text;
		ls_text = "                  " + ls_text;
		ls_text = ls_text.Right(13);
		ls_text = "卡余额(BALANCE):" + ls_text;
		MoveToEx(hdcprint, 0, li_jump, NULL);
		TextOutA(hdcprint, 0, li_jump, ls_text, ls_text.GetLength());

		li_jump += 35;
		MoveToEx(hdcprint, 0, li_jump, NULL);
		ls_text = "-------------------------------------------------------";
		TextOutA(hdcprint, 0, li_jump, ls_text, ls_text.GetLength());
		
		RestoreDC(hdcprint, -1); //恢复打印机设备句柄
		EndPage(hdcprint); //打印机停纸,停止打印
		EndDoc(hdcprint); //结束一个打印作业
		MessageBox(_T("打印完毕!"), _T("提示"), MB_ICONINFORMATION);
	}
	// 用API函数DeleteDC销毁一个打印机设备句柄              
	DeleteDC(hdcprint);
}

void CW_cqrk::OnSize(UINT nType, int cx, int cy)
{
	CDialogEx::OnSize(nType, cx, cy);

	CRect rect;
	CRect lc_kuang;
	GetClientRect(&rect);	
	if(IsWindow(m_con_kuang.GetSafeHwnd()))
	{
		m_con_kuang.MoveWindow(180, 40, rect.right-185, 250);
	}
	if(IsWindow(m_list_yhzc.GetSafeHwnd()))
	{
		GetDlgItem(IDC_STATIC1)->GetWindowRect(&lc_kuang);
		m_list_yhzc.MoveWindow(10, lc_kuang.Height() + 50, 300, rect.bottom-lc_kuang.Height() - 110);
	}
	if(IsWindow(m_list.GetSafeHwnd()))
	{
		GetDlgItem(IDC_STATIC1)->GetWindowRect(&lc_kuang);
		m_list.MoveWindow(320, lc_kuang.Height() + 50, rect.right-16 - 310 , rect.bottom-lc_kuang.Height() - 110);
	}
}


BOOL CW_cqrk::OnInitDialog()
{
	CDialogEx::OnInitDialog();

	m_con_czje.SetFont(&theApp.g_font1);
	m_con_wded.SetFont(&theApp.g_font1);
	m_con_zsje.SetFont(&theApp.g_font1);
	m_con_klx.SetFont(&theApp.g_font1);

	m_list_yhzc.InsertColumn(0,_T("起始充值金额"),LVCFMT_CENTER,90);
	m_list_yhzc.InsertColumn(1,_T("截止充值金额"),LVCFMT_CENTER,90);
	m_list_yhzc.InsertColumn(2,_T("赠送金额"),LVCFMT_CENTER,110);	
	m_list_yhzc.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES|WS_HSCROLL);	

	m_list.InsertColumn(0,_T("会员账号"),LVCFMT_CENTER,80);
	m_list.InsertColumn(1,_T("会员卡号"),LVCFMT_CENTER,80);
	m_list.InsertColumn(2,_T("会员姓名"),LVCFMT_CENTER,80);
	m_list.InsertColumn(3,_T("会员性别"),LVCFMT_CENTER,80);
	m_list.InsertColumn(4,_T("固定电话"),LVCFMT_CENTER,100);
	m_list.InsertColumn(5,_T("移动电话"),LVCFMT_CENTER,100);
	m_list.InsertColumn(6,_T("所属公司"),LVCFMT_CENTER,120);
	m_list.InsertColumn(7,_T("车牌号码"),LVCFMT_CENTER,80);
	m_list.InsertColumn(8,_T("账户金额"),LVCFMT_CENTER,80);
	m_list.InsertColumn(9,_T("优惠金额"),LVCFMT_CENTER,80);
	m_list.InsertColumn(10,_T("开卡人员"),LVCFMT_CENTER,80);
	m_list.InsertColumn(11,_T("开卡网点"),LVCFMT_CENTER,120);
	m_list.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES|WS_HSCROLL);	

	m_con_hyxb.AddString(_T("男"));
	m_con_hyxb.AddString(_T("女"));

	m_con_czfs.AddString(_T("总部收款"));
	m_con_czfs.AddString(_T("站点收款"));
	m_con_czfs.AddString(_T("预充未收款"));

	m_con_czje.SetLimitText(6);
	m_con_zsje.SetLimitText(6);
	m_con_czje.SetFont(&theApp.g_font1);
	m_con_zsje.SetFont(&theApp.g_font1);
	m_con_wded.SetFont(&theApp.g_font1);

	is_hyzh = _T("");
	ii_klx = 0;

	f_geted();
	f_getyhzc();

	return TRUE;
}

void CW_cqrk::OnBnClickedButton1()
{
	HANDLE lh_hand;
	int li_ret;
	unsigned long ll_kh=0, ll_val1=0, ll_val2=0, ll_val3=0, ll_nkh=0;
	unsigned int  li_klb=0, li_xkf=0; 
	unsigned char lc_nkhh[20];
	CStringA ls_nkhh_a;
	CString  ls_nkhh;
	CF_CONNECT f_connect;
	ns4__lc_USCOREdata l_info;
	CString ls_stra;
	CString ls_suba;
	CString ls_zid;
	CString ls_wkhm;
	int li_rowa, i;
	CString ls_err;

	hDll = LoadLibrary(_T("z_hbxj.dll"));
	if (hDll == NULL)
	{	
		MessageBox(_T("装载动态库出错,无法对卡操作!"), _T("系统提示"), MB_ICONWARNING);
		return;
	}
	OpenComm = (p_opencomm)GetProcAddress(hDll,"OpenComm");
	CloseComm = (p_closecomm)GetProcAddress(hDll,"CloseComm");
	ReadCard  = (p_readcard)GetProcAddress(hDll,"Hw_Red_UserCard");
	
	lh_hand = OpenComm(0);
	if (lh_hand <= 0)
	{
		MessageBox(_T("打开读卡器失败!"), _T("系统提示"), MB_ICONWARNING);
		return;
	}

	memset(lc_nkhh,0,sizeof(lc_nkhh));
	li_ret = ReadCard(lh_hand, &ll_kh, &ll_val1, &ll_val2, &ll_val3, &li_klb, &li_xkf, &ll_nkh, lc_nkhh);
	if (li_ret != 0)
	{
		CloseComm(lh_hand);
		ls_err.Format(_T("读卡信息失败!  [ %d ]"), li_ret);
		MessageBox(ls_err, _T("系统提示"), MB_ICONWARNING);
		return;
	}
	CloseComm(lh_hand);

	OnBnClickedButton2();

	if (li_klb == 1)
	{
		m_con_klx.SetWindowTextW(_T("主卡"));
	}
	else if (li_klb == 2)
	{
		m_con_klx.SetWindowTextW(_T("标准卡"));
	}
	else if (li_klb == 3)
	{		
		m_con_klx.SetWindowTextW(_T("管理员卡"));		
	}
	ii_klx = li_klb;
	ls_nkhh_a.Format("%s", lc_nkhh);
	ls_nkhh = ls_nkhh_a;
	ls_wkhm.Format(_T("%d"), ll_kh);
		
	l_info.CMD = "BG";	
	l_info.VALUE01 = f_connect.f_getstd(ls_nkhh);
	l_info.VALUE02 = f_connect.f_getstd(theApp.gs_bcode);
	ls_stra = f_connect.f_server(l_info);
	if (f_connect.f_getsub(ls_stra,1) == "ZZ00")
	{		
		li_rowa = _ttoi(f_connect.f_getsub(ls_stra,2));	
		if (li_rowa > 0)
		{
			m_list.DeleteAllItems();
			for (i=0; i<li_rowa; i++)
			{
				ls_suba = f_connect.f_getsub(ls_stra,4+i);

				m_list.InsertItem(i,f_connect.f_getsub_col(ls_suba,1));
				m_list.SetItemText(i,1, f_connect.f_getsub_col(ls_suba,2));
				m_list.SetItemText(i,2, f_connect.f_getsub_col(ls_suba,3));	
				m_list.SetItemText(i,3, f_connect.f_getsub_col(ls_suba,4));
				m_list.SetItemText(i,4, f_connect.f_getsub_col(ls_suba,5));
				m_list.SetItemText(i,5, f_connect.f_getsub_col(ls_suba,6));
				m_list.SetItemText(i,6, f_connect.f_getsub_col(ls_suba,7));
				m_list.SetItemText(i,7, f_connect.f_getsub_col(ls_suba,8));
				m_list.SetItemText(i,8, f_connect.f_getsub_col(ls_suba,9));
				m_list.SetItemText(i,9, f_connect.f_getsub_col(ls_suba,10));
				m_list.SetItemText(i,10, f_connect.f_getsub_col(ls_suba,11));
				m_list.SetItemText(i,11, f_connect.f_getsub_col(ls_suba,12));
				m_con_wded.SetWindowTextW(f_connect.f_getsub_col(ls_suba, 16));
			}
		}
	}
	else if (f_connect.f_getsub(ls_stra,1) == "ZZ01")
	{
		MessageBox(f_connect.f_getsub(ls_stra,2),_T("系统提示"), MB_ICONWARNING);
	}
}


void CW_cqrk::OnBnClickedButton2()
{
	m_con_hyzh.SetWindowTextW(_T(""));
	m_con_wkhm.SetWindowTextW(_T(""));
	m_con_hyxm.SetWindowTextW(_T(""));
	m_con_gddh.SetWindowTextW(_T(""));
	m_con_yddh.SetWindowTextW(_T(""));
	m_con_sfzh.SetWindowTextW(_T(""));
	m_con_cphm.SetWindowTextW(_T(""));
	m_con_zhje.SetWindowTextW(_T(""));
	m_con_yhje.SetWindowTextW(_T(""));
	m_con_czy.SetWindowTextW(_T(""));
	m_con_kkwd.SetWindowTextW(_T(""));
	m_con_klx.SetWindowTextW(_T(""));

	m_con_hyxb.ResetContent();
	m_con_hyxb.AddString(_T("男"));
	m_con_hyxb.AddString(_T("女"));

	m_con_czfs.ResetContent();
	m_con_czfs.AddString(_T("总部收款"));
	m_con_czfs.AddString(_T("站点收款"));
	m_con_czfs.AddString(_T("预充未收款"));

	m_con_czje.SetWindowTextW(_T(""));
	m_con_zsje.SetWindowTextW(_T(""));
	
	m_list.DeleteAllItems();

	is_hyzh = _T("");
}


void CW_cqrk::OnNMDblclkList2(NMHDR *pNMHDR, LRESULT *pResult)
{
	LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
	int row;

	row = pNMItemActivate->iItem;
	if (row < 0)
	{
		return;
	}
		
	m_con_hyzh.SetWindowTextW(m_list.GetItemText(row,0));
	m_con_wkhm.SetWindowTextW(m_list.GetItemText(row,1));
	m_con_hyxm.SetWindowTextW(m_list.GetItemText(row,2));	
	m_con_hyxb.SelectString(0,m_list.GetItemText(row,3));
	m_con_gddh.SetWindowTextW(m_list.GetItemText(row,4));	
	m_con_yddh.SetWindowTextW(m_list.GetItemText(row,5));
	m_con_sfzh.SetWindowTextW(m_list.GetItemText(row,6));
	m_con_cphm.SetWindowTextW(m_list.GetItemText(row,7));
	m_con_zhje.SetWindowTextW(m_list.GetItemText(row,8));
	m_con_yhje.SetWindowTextW(m_list.GetItemText(row,9));
	m_con_czy.SetWindowTextW(m_list.GetItemText(row,10));
	m_con_kkwd.SetWindowTextW(m_list.GetItemText(row,11));

	is_hyzh = m_list.GetItemText(row,0);
	m_con_czje.SetFocus();
		
	*pResult = 0;
}


void CW_cqrk::OnEnChangeEdit25()
{
	CString ls_czje;
	CString ls_zsje;
    m_con_czje.GetWindowText(ls_czje);
	int li_count=0, i=0;
	CString ls_bbje, ls_eeje;
	
	if (ii_klx == 3)
	{
		m_con_zsje.SetWindowTextW(_T("0"));
		return;
	}
	if (ls_czje.GetLength() == 0)
	{
		m_con_zsje.SetWindowTextW(_T("0"));
	}

	if (m_list_yhzc.GetItemCount() == 0)
	{
		m_con_zsje.SetWindowTextW(_T("0"));
	}
	else
	{
		li_count = m_list_yhzc.GetItemCount();
		if (li_count > 0)
		{
			ls_zsje = _T("0");
			for (i=0; i<li_count; i++)
			{
				ls_bbje = m_list_yhzc.GetItemText(i,0);
				ls_eeje = m_list_yhzc.GetItemText(i,1);
				if ((_ttol(ls_bbje) < _ttol(ls_czje))&&(_ttol(ls_czje) <= _ttol(ls_eeje)))
				{
					ls_zsje = m_list_yhzc.GetItemText(i,2);					
					break;
				}
			}
			m_con_zsje.SetWindowTextW(ls_zsje);
		}
	}
}

void CW_cqrk::f_geted()
{
	CF_CONNECT f_connect;
	ns4__lc_USCOREdata l_info;
	CString ls_stra, ls_suba;
	CString ls_a01;

	l_info.CMD = "BI";
	l_info.VALUE01 = f_connect.f_getstd(theApp.gs_bcode);
	ls_stra = f_connect.f_server(l_info);
	if (f_connect.f_getsub(ls_stra,1) == "ZZ00")
	{		
		ls_suba = f_connect.f_getsub(ls_stra,4);
		m_con_wded.SetWindowTextW(f_connect.f_getsub_col(ls_suba,1));
	}
	else if (f_connect.f_getsub(ls_stra,1) == "ZZ01")
	{
		MessageBox(f_connect.f_getsub(ls_stra,2),_T("系统提示"), MB_ICONWARNING);
	}
}

void CW_cqrk::f_getyhzc()
{
	CF_CONNECT f_connect;
	ns4__lc_USCOREdata l_info;
	CString ls_stra, ls_suba;
	int li_rowa=0, i=0;

	l_info.CMD = "BO";
	l_info.VALUE01 = f_connect.f_getstd(theApp.gs_opid);
	ls_stra = f_connect.f_server(l_info);
	if (f_connect.f_getsub(ls_stra,1) == "ZZ00")
	{	
		li_rowa = _ttoi(f_connect.f_getsub(ls_stra,2));
		for (i=0; i<li_rowa; i++)
		{
			ls_suba = f_connect.f_getsub(ls_stra,4+i);
			m_list_yhzc.InsertItem(i,f_connect.f_getsub_col(ls_suba,1));
			m_list_yhzc.SetItemText(i,1,f_connect.f_getsub_col(ls_suba,2));
			m_list_yhzc.SetItemText(i,2,f_connect.f_getsub_col(ls_suba,3));
		}
	}
	else if (f_connect.f_getsub(ls_stra,1) == "ZZ01")
	{
		MessageBox(f_connect.f_getsub(ls_stra,2),_T("系统提示"), MB_ICONWARNING);
	}
}